/**
 * Copyright &copy; 2015-2020 <a href="http://www.easyhis.com/">easyhis</a> All rights reserved.
 */
package com.easy.modules.monitor.entity;


import com.easy.common.utils.IdGen;
import com.easy.common.utils.excel.annotation.ExcelField;
import com.easy.core.persistence.BaseEntity;
import com.easy.modules.sys.entity.User;
import com.easy.modules.sys.utils.UserUtils;

import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 定时任务Entity
 * @author lgf
 * @version 2017-02-04
 */
public class ScheduleJob extends BaseEntity<ScheduleJob> {
	
	private static final long serialVersionUID = 1L;
	private String id;
	private Integer schedId;
	private String schedName;		// 任务名
	private String schedGroup;		// 任务组
	private String schedExpression;		// 定时规则
	private String status;		// 启用状态
	private String isInfo;		// 通知用户
	private String className;		// 任务类
	private String schedDesc;		// 描述
	private User createBy;	// 创建者
	private Date createTime;	// 创建日期
	private User updateBy;	// 更新者
	private Date updateTime;	// 更新日期
	private Integer delFlag; 	// 删除标记（0：正常；1：删除；2：审核）

	public ScheduleJob() {
		super();
	}

	public ScheduleJob(Integer schedId){
		this.schedId = schedId;
	}

	public ScheduleJob(String id){
		this.id = id;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@NotNull(message="任务名不能为空")
	@ExcelField(title="任务名", align=2, sort=1)
	public String getSchedName() {
		return schedName;
	}

	public void setSchedName(String schedName) {
		this.schedName = schedName;
	}
	
	@NotNull(message="任务组不能为空")
	@ExcelField(title="任务组", dictType="schedule_group", align=2, sort=2)
	public String getSchedGroup() {
		return schedGroup;
	}

	public void setSchedGroup(String schedGroup) {
		this.schedGroup = schedGroup;
	}
	@NotNull(message="定时规则不能为空")
	@ExcelField(title="定时规则", align=2, sort=3)
	public String getSchedExpression() {
		return schedExpression;
	}

	public void setSchedExpression(String schedExpression) {
		this.schedExpression = schedExpression;
	}
	
	@NotNull(message="启用状态不能为空")
	@ExcelField(title="启用状态", dictType="yes_no", align=2, sort=4)
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	@ExcelField(title="通知用户", dictType="schedule_task_info", align=2, sort=5)
	public String getIsInfo() {
		return isInfo;
	}

	public void setIsInfo(String isInfo) {
		this.isInfo = isInfo;
	}
	
	@NotNull(message="任务类不能为空")	
	@ExcelField(title="任务类", align=2, sort=6)
	public String getClassName() {
		return className;
	}

	public void setClassName(String className) {
		this.className = className;
	}
	
	@ExcelField(title="描述", align=2, sort=7)
	public String getSchedDesc() {
		return schedDesc;
	}

	public void setSchedDesc(String schedDesc) {
		this.schedDesc = schedDesc;
	}

	public Integer getSchedId() {
		return schedId;
	}

	public void setSchedId(Integer schedId) {
		this.schedId = schedId;
	}

	public User getCreateBy() {
		return createBy;
	}

	public void setCreateBy(User createBy) {
		this.createBy = createBy;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public User getUpdateBy() {
		return updateBy;
	}

	public void setUpdateBy(User updateBy) {
		this.updateBy = updateBy;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getDelFlag() {
		return delFlag;
	}

	public void setDelFlag(Integer delFlag) {
		this.delFlag = delFlag;
	}

	/**
	 * 插入之前执行方法，需要手动调用
	 */
	public void preInsert(){
		this.id = IdGen.uuid();
		User user = UserUtils.getUser();
		if (user.getUserId()<1){
			this.updateBy = user;
			this.createBy = user;
		}
		this.updateTime = new Date();
		this.createTime = this.updateTime;
	}

	/**
	 * 更新之前执行方法，需要手动调用
	 */
	public void preUpdate(){
		User user = UserUtils.getUser();
		if (user.getUserId()<1){
			this.updateBy = user;
		}
		this.updateTime = new Date();
	}
}